<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>404</title>
    <link rel="stylesheet" href="../assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="../assets/module/admin.css?v=313"/>
    <link rel="stylesheet" href="../assets/css/error-page.css"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<!-- 加载动画 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<!-- 正文开始 -->
<div class="error-page">

    <div class="error-page-info">
        <div class="error-page-info-desc">模板测试页</div>

        <div id="tplbtn"></div>
        <div id="list"></div>

        <div id="laytpl_view"></div>
    </div>
</div>

<!-- js部分 -->
<script type="text/javascript" src="../assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="../assets/js/common.js?v=313"></script>

<script src="../assets/libs/template-web.js"></script>

<script>
    layui.use(['admin'], function () {
        var $ = layui.jquery;
        var admin = layui.admin;

    });
</script>

<script id="tpl-btn" type="text/html">
    {{if hasPermission(1)}}
        <button type="button" class="layui-btn">{{title}}</button>
    {{else }}
    <button type="button" class="layui-btn layui-btn-disabled">{{title2}}</button>
    {{/if}}
</script>
<script id="test" type="text/html">
    {{if isAdmin}}
    <h4>{{title}}</h4>
    <ul>
        {{each list as value i}}
        <li>索引 {{i + 1}} ：{{value}}</li>
        {{/each}}
    </ul>
    {{/if}}
</script>
<!--自定义函数判断权限-->
<script>
    template.defaults.imports.hasPermission = function(data){
        console.log(data)
        if(data === 1){
            return true;
        }
        if(data === 2){
            return true;
        }
        return false;
    };
</script>
<script>
    var btnData = {
        type:1,
        title:'可点击状态',
        title2:'不可点击状态'
    }
    var html = template('tpl-btn', btnData);
    document.getElementById('tplbtn').innerHTML = html;

    var data = {
        title: '基本例子',
        isAdmin: true,
        list: ['文艺', '博客', '摄影', '电影', '民谣', '旅行', '吉他']
    };
    var html = template('test', data);
    document.getElementById('list').innerHTML = html;


</script>
</body>
</html>